using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UpgradeParallelProjectiles:Upgrade {

	public override void OnEnable() {
		base.OnEnable();
	}
	Dictionary<object,Vector2> forwards = new Dictionary<object,Vector2>();
	protected override void ProjectileFiredEventHandler(object _sender,ProjectileEventArgs e) {
		base.ProjectileFiredEventHandler(_sender,e);
		if(!forwards.ContainsKey(_sender)) return;
		Vector2 newForward = (_sender as Projectile).forward;
		float angleDelta = ((Angle)newForward-(Angle)forwards[_sender]).degree;
		if(angleDelta>180) angleDelta-=360;
		(_sender as Projectile).transform.position+=(Vector3)Utility.Product(forwards[_sender],Vector2.up)*(angleDelta*0.05f);
		(_sender as Projectile).forward=forwards[_sender];
		forwards.Remove(_sender);
	}
	protected override void ProjectileFiringEventHandler(object _sender,ProjectileEventArgs e) {
		base.ProjectileFiringEventHandler(_sender,e);
		forwards.Add(_sender,(_sender as Projectile).forward);
	}

}
